﻿<UserControl x:Class="Notoric.View.Music.CWNotation.Controls.Chord"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:vme="clr-namespace:Notoric.ViewModel.Elements.CWNotation;assembly=ViewModel"
             xmlns:my="clr-namespace:Notoric.View.Music.CWNotation.Controls"
             DataContextChanged="UserControl_DataContextChanged">
    <Canvas>
        <ItemsControl ItemsSource="{Binding LedgerLines}" IsHitTestVisible="False">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Canvas Background="Transparent"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate DataType="{x:Type vme:LedgerLine}">
                    <Canvas>
                        <Line X1="{Binding X1, Mode=OneWay}" X2="{Binding X2, Mode=OneWay}" Y1="{Binding Y, Mode=OneWay}" Y2="{Binding Y, Mode=OneWay}"
                              StrokeThickness="0.02cm" Stroke="Black"/>
                    </Canvas>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
        <ItemsControl ItemsSource="{Binding Notes}" Panel.ZIndex="2">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Canvas Background="Transparent"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate DataType="{x:Type vme:Note}">
                    <Canvas>
                        <my:Note DataContext="{Binding}"/>
                    </Canvas>
                </DataTemplate>         
            </ItemsControl.ItemTemplate>
        </ItemsControl>
        <Line StrokeThickness="0.02cm" X1="{Binding Position, Mode=OneWay}" X2="{Binding Position, Mode=OneWay}" Y1="{Binding StemStart, Mode=OneWay}"
              Y2="{Binding StemEnd, Mode=OneWay}" Stroke="Black" IsHitTestVisible="False"/>
        <ItemsControl ItemsSource="{Binding Flags}" IsHitTestVisible="False">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Canvas Background="Transparent"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate DataType="{x:Type vme:Flag}">
                    <Canvas>
                        <my:Flag DataContext="{Binding}"/>
                    </Canvas>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
        <TextBlock x:Name="PART_ArticulationSymbol" FontFamily="MusicalSymbols" FontSize="{Binding EffectiveTypeSize, Mode=OneWay}"
                   Canvas.Left="{Binding Position, Mode=OneWay}" Canvas.Top="{Binding ArticulationPosition, Mode=OneWay}"/>
    </Canvas>
</UserControl>
